Repository navigation
Conversation
The desktop package ships the game's HTML/JS/assets as plain files next to the ASAR, so they could be edited in place. The builder now records the SHA-256 of every shipped game file (integrity.json, inside the ASAR) and the host checks each file against it before serving it. A file that was changed or added shows an error and quits. The bytes that were checked are the bytes that are served, so a file cannot be swapped between the check and the read.
… bypassed The check of the game files lives inside the ASAR, so the ASAR has to be protected too. Flip the Electron fuses on the packaged runtime: - validate the ASAR against the hash the packager embeds in the executable (macOS and Windows; Electron has no such validation on Linux) - load the app only from the ASAR - ignore ELECTRON_RUN_AS_NODE, NODE_OPTIONS and the inspect switches Verified on Windows: a patched ASAR does not start, a modified game file shows the error, the original package runs. Not yet run on macOS (the fuses are flipped before signing, with the ad-hoc signature reset on Apple silicon).
…vTools) The developer tools let anyone read and change the running game. They are now disabled in the window unless electron.config.json sets "devTools": true, which also adds the usual shortcut (F12 or Ctrl/Cmd+Shift+I; there is no application menu to carry it). Meant for a development config file (NEXT2D_ELECTRON_CONFIG_FILE), not for builds that are distributed.
The native host now checks the game's script files (.js .mjs .html .json .wasm) against SHA-256 hashes recorded at build time: - platform/AssetIntegrity.h (header only): SHA-256, the list of hashes and the check. A listed file must match; a script that is not listed is not read. Media files are not checked, so nothing is hashed on their load path. - AssetLoader (ReadBinary / ReadText / OpenStream / entry module), V8Runtime::LoadModule and the host scripts (bootstrap.js) go through it. - Host core API: next2d_host_set_asset_integrity(manifest), called before next2d_host_create. Without it nothing is checked (as before). - Xbox: the builder writes the hashes of the embedded scripts into src/AssetIntegrityManifest.h, so they are compiled into the executable. Unit test: tests/integrity_test.cpp (SHA-256 test vectors and the rules), added to CI and check_local.sh. The Xbox executable itself (main.cpp) is not built here; it is covered by the Xbox CI build.
…ot yet run on a device) After `cap sync`, record the SHA-256 of the scripts in the native project and add native code that verifies them when the app starts: - Android: a ContentProvider (app.next2d.integrity.Next2DAssetIntegrity) runs before the app and compares assets/public and the Capacitor config files with hashes compiled into a generated class (kept out of git by a local .gitignore). One <provider> is added to AndroidManifest.xml. - iOS: a block appended to AppDelegate.swift, called first in didFinishLaunchingWithOptions, compares the bundle with public/next2d-integrity.txt. - `cap run` (preview) writes an empty list so development runs are not blocked. The generators are covered by unit tests, and the Android path runs in the existing `cap sync` test. The generated Java and Swift have NOT been compiled or run: this machine has no Android SDK and no macOS. Verify on a device before merging.
Feature/asset integrity
capacitor: check the packaged scripts at launch on Android and iOS (n…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.